package com.bosc.modeling.controller;

import com.bosc.modeling.common.BaseController;
import com.bosc.modeling.common.ResponseFactory;
import com.bosc.modeling.service.StatisticsInfoService;
import com.bosc.modeling.utils.SpringUtil;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class StatisticsInfoController extends BaseController {
    @Autowired
    StatisticsInfoService statisticsInfoService;
    @RequestMapping(value = "/statistics_info",method = RequestMethod.GET)
    public Object statisticsInfo(){
        long usersNum = statisticsInfoService.countUsers();
        long competitiosNum = statisticsInfoService.countCompetitions();
        Map data = new HashMap();
        data.put("user_num",usersNum);
        data.put("competition_num", competitiosNum);
        data.put("unstart_num", statisticsInfoService.countUnstartCompetitions());
        data.put("A_num", statisticsInfoService.countACompetitions());
        data.put("B_num", statisticsInfoService.countBCompetitions());
        data.put("end_num", statisticsInfoService.countEndCompetitions());
        log.info("statisticsInfo:"+data);
        return ResponseFactory.successResponse(data);
    }
}
